layui.use('form', function(){
    var form = layui.form;
    //自定义验证规则
    form.verify({
        //用户名检查
        userName:[
            /^[a-zA-Z0-9]{6,16}$/,
            "用户名不合法!"
        ],
        //密码检查
        userPwd : [
            /^[a-zA-Z0-9]{6,16}$/,
            "密码不合法！"
        ]
    });
    //监听提交事件,监听按钮名为formDemo
    form.on('submit(formDemo)', function(data){
       // layer.msg(JSON.stringify(data.field));
       // 获取json的值
        var jsonData=JSON.stringify(data.field);
        //异步通讯发送数据
        $.post("/springbootLesson/loginMain",data.field, function (result) {
            if(result.success){
                //页面跳转，进入系统，controller的地址
                window.location.href="/springbootLesson/main"
            }
        },"json")
        return false;
    });
});